package com.example.basic.service;

import com.example.basic.entity.User;
import com.example.basic.exception.MyCustomException;
import com.example.basic.exception.ExceptionEnum;
import com.example.basic.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName: UserService
 * Description: 用户 service
 * date: 2021/12/14 9:40
 * author zesion lee
 */
@Service
public class UserService {
    @Resource
    UserMapper userMapper;

    public User getUserInfoById(Integer id) {
        User user = userMapper.selectByPrimaryKey(id);
        if (user == null) {
            throw new MyCustomException(ExceptionEnum.USER_NOT_EXIST);
        }

        return user;
    }
}
